<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simpla Admin</title>
<include file="Admin:Resources" />
<script>
$(document).ready(function(){

	//var obj = $('.table_row').children(".drag_span:last-child").find('a').eq(-2).html(); 
	
	KindEditor.ready(function(K) {
		
		$('.table_row').each(function(){
				
			var _This = $(this);
			
			var obj =  _This.children(".drag_span:last-child").find('a').eq(-1); 
			
			var dayinObj =  _This.children(".drag_span:last-child").find('a').eq(-2); 
			
			dayinObj.click(function(){
				
				if(!confirm('打印报名表会锁定,确定执行该操作？')){
					
					return false;
				}else{
					window.open($(this).attr('href')); return false;
				}
			});
			
			obj.click(function(){
				
				var rowThis = $(this);  //cm_list_check
				var student_id = rowThis.parent().parent().find('.cm_list_check').val();   //alert(student_id); 
				var mhref = rowThis.attr('href');
				
				$.post('__APP__/Student/getStuInfo',{'student_id':student_id},function(data){
					
					var mData = JSON.parse(data);
					
					if(mData=='1'){
						alert('已经完善分组号等信息，马上打印');
						window.open(mhref); return false;
					}else{
						
						var content = [
						'<div style="margin:10px; text-align:center; min-height:260px;">',
						'面谈分组号：<input name="fenzu" type="text" style="width:200px; height:22px;margin-bottom:8px; margin-top:60px;"  /><br>',
						'选择&nbsp;&nbsp;&nbsp;时段：<select style="min-width:180px; height:30px; width:204px;" class="acti_times" name="acti_time">',
						'<option value="0" >---请选择时段---</option>',
						<?php foreach($actiTimes as $val){ ?>
							
							'<option value={$val["acti_time_id"]} >{$val["title"]}</option>',
						<?php } ?>
						'</select>',
						'<p id="mess" style="display:none; margin-top:60px; font-size:16px;">提醒管理员注意：该时段目前还剩余,<font id="mess_num" color="red">0</font>个座位号没有分配</p>',
						'</div>'
					];
					var str = content.join('');
					//str = $('#myDialog').html();
					//alert(str);
					
					var dialog = K.dialog({
						width : 500,
						title : '信息完善',
						body : str,
						closeBtn : {
							name : '关闭',
							click : function(e) {
								dialog.remove();
							}
						},
						yesBtn : {
							name : '确定',
							click : function(e) {
								
								var fenzu 		= $('input[name="fenzu"]').val(); 
								var acti_time   = $('select[name="acti_time"]').val(); 
								
								if(fenzu==''){ alert('请填写分组信息'); return false;}
								if(acti_time=='0'){ alert('请填选择时段'); return false;}
								if($('#mess_num2').html()==0){ alert('当前时段已经没有座位'); return false;}
								
								$.post('__APP__/Student/addBao',{'fenzu':fenzu,'acti_time':acti_time,'student_id':student_id},function(data){
									
									if(data==0){
										
										alert('分配座位失败，该时段座位已用完');
										return false;
									}
									
									dialog.remove();
									///index.php/Student/dayin/student_id/36.html
									window.open(mhref); return false;
								});
								
							}
						},
						noBtn : {
							name : '取消',
							click : function(e) {
								dialog.remove();
							}
						}
					});
					}
				});
				
				
				
				return false;
				
			});
			
		});	


		$("body").delegate(".acti_times","change",function(){
			
			var val = $(this).val(); 
			
			$.post('__APP__/Student/getNums',{'acti_time_id':val},function(data){
				
				$('#mess_num').html(data);
				$('#mess_num2').html(data);
				
				if(data<=2){
					
					$('#mess').css({'display':'block'});
				}else{
					$('#mess').css({'display':'none'});
				}
				
			});
		});
	});
	
	
	
});
</script>
</head>
<body>
<div style="-display:none;" id="mess_num2"></div>
<!--
	<div id="myDialog">
		<div style="margin:10px; text-align:center;">
			面谈分组号：<input name="" value="" /><br>
			选择时段：
			<select style="min-width:180px;" name="">
				<?php foreach($actiTimes as $val){ ?>
				<option value="{$val['acti_time_id']}" >{$val['title']}</option>
				<?php } ?>
				
			</select>
		</div>
	</div>
-->
	<div id="body-wrapper" style="margin-top:20px;"> 
		<div id="main-content"> 
			<div class="content-box">
				
				<div class="content-box-header">
					
					<h3>列表</h3>
					
					<ul id="my_tab">
						<li>{$excel_btn}</li>
						
						<li>&nbsp;{$add_btn}</li>
					</ul>
					<div class="clear"></div>
				</div> 
				
				{$searchForm}
				<div class="content-box-contenta">
					
					{$list}
				</div> 
				
			</div>
		<div class="clear"></div>
			
		</div> 
</div>
	
</body>
</html>
